Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support setters #62

Merged
merged 3 commits into from
Jan 11, 2024
Merged

Support setters #62

merged 3 commits into from
Jan 11, 2024

Conversation

luisherranz
Copy link
Owner

What

Fixes #47.

Adds support for setters, like:

const store = deepSignal({
  counter: 1,
  get double() {
    return store.counter * 2;
  },
  set double(val) {
    store.counter = val / 2;
  },
});

store.counter // 1

store.double = 4;

store.counter // 2

Why

Because setters are useful.

How

By shortcircuiting the set handler when the property has a setter.

@luisherranz luisherranz self-assigned this Jan 11, 2024
Copy link
Contributor

Size Change: +151 B (+2%)

Total Size: 6.38 kB

Filename Size Change
packages/deepsignal/core/dist/deepsignal-core.js 1.04 kB +25 B (+2%)
packages/deepsignal/core/dist/deepsignal-core.mjs 1.03 kB +25 B (+2%)
packages/deepsignal/dist/deepsignal.js 1.07 kB +24 B (+2%)
packages/deepsignal/dist/deepsignal.mjs 1.07 kB +24 B (+2%)
packages/deepsignal/react/dist/deepsignal-react.js 1.09 kB +26 B (+2%)
packages/deepsignal/react/dist/deepsignal-react.mjs 1.09 kB +27 B (+3%)

compressed-size-action

@luisherranz luisherranz merged commit 13ccbb9 into main Jan 11, 2024
3 checks passed
@luisherranz luisherranz deleted the support-setters branch January 11, 2024 20:47
@github-actions github-actions bot mentioned this pull request Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support setters
1 participant